from selenium import webdriver
import time
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains

def export():
    url = 'https://132.122.251.27:31943/ossfacewebsite/index.html#Access/Access_RANWizard'
    driver = webdriver.Chrome()
    #进入页面
    driver.get(url)
    #最大化窗口
    driver.maximize_window()
    time.sleep(1)
    #高级
    driver.find_element('xpath','//*[@id="details-button"]').click()
    #仍然进入
    driver.find_element('xpath','//*[@id="proceed-link"]').click()
    time.sleep(1)
    #登录
    driver.find_element('xpath','//*[@id="username"]').send_keys('dengrens')
    driver.find_element('xpath','//*[@id="value"]').send_keys('Rr.33557799')
    driver.find_element('xpath','//*[@id="submitDataverify"]').click()
    time.sleep(6)
    #切入iframe
    driver.switch_to.frame('cmReports')
    time.sleep(2)
    #关弹窗
    driver.find_element(By.CLASS_NAME,'eui_Dialog_closeIcon').click()
    time.sleep(1)
    #NR
    driver.find_element('xpath','//*[@id="eui_Accordions_10000"]/ul/li[3]/ul/li[3]/div/a/span[2]').click()
    time.sleep(1)
    #NR RRU
    driver.find_element('xpath','//*[@id="eui_checkbox_10011_span"]').click()
    time.sleep(1)
    #下一步
    driver.find_element('xpath','//*[@id="dialog_panel"]/div[5]/button[2]/span').click()
    time.sleep(1)
    #选网元
    driver.find_element('xpath','//*[@id="dialog_panel"]/div[3]/div/div/div[2]/div/div/div[3]/div[3]/div[1]/div[2]').click()
    time.sleep(1)
    #完成
    driver.find_element('xpath','//*[@id="dialog_panel"]/div[5]/button[3]/span').click()
    time.sleep(1)
    #切最外层
    driver.switch_to.default_content()
    #点搜索
    driver.find_element('xpath','//*[@id="refr.mm.search"]').click()
    time.sleep(1)
    #输入
    driver.find_element('xpath','//*[@id="febs-refr"]/div/div[4]/div/div/div[1]/div/div/label/input').send_keys('存量管理')
    time.sleep(1)
    driver.find_element('xpath','//*[@id="febs-refr"]/div/div[4]/div/div/div[1]/div/div/label/input').send_keys(Keys.ENTER)
    time.sleep(5)
    #切入iframe
    driver.switch_to.frame('Access_InventoryManageMent')
    time.sleep(1)
    #点导出
    driver.find_element('xpath','//*[@id="root"]/div/div/div[1]/div[1]/div/div[1]/div/div/div[1]/span[2]').click()
    time.sleep(1)
    #选网元
    driver.find_element('xpath','//*[@id="dialog_panel"]/div[3]/div[1]/div[2]/div[3]/div[3]/div[1]/div[2]').click()
    time.sleep(1)
    #下拉框
    driver.find_element('xpath','//*[@id="eui_ms_1000_eui_ms"]/div').click()
    time.sleep(1)
    #板
    driver.find_element('xpath','/html/body/div[5]/div/div/div/div/div[3]/div/span').click()
    time.sleep(1)
    #点击任意出
    driver.find_element('xpath','//*[@id="dialog_panel"]/div[2]/div').click()
    time.sleep(1)
    #导出
    driver.find_element('xpath','//*[@id="dialog_panel"]/div[5]/button[2]').click()
    time.sleep(3)
    #确定
    driver.find_element('xpath','//*[@id="eui_MessageDialog_10003"]/div[2]/div[3]/button').click()
    time.sleep(1)
    #跳转RAN报表
    driver.get('https://132.122.251.27:31943/ossfacewebsite/index.html#Access/Access_RANWizard@@cmReports?switch=undefined&maeUrl=%2Fomc%2Fcm%2Findex.html%23%2Freport%3Ftype%3DranReport&maeTitle=RAN%E6%8A%A5%E8%A1%A8&loadType=iframe')
    driver.switch_to.frame('cmReports')
    #等
    time.sleep(360)
    #下载RAN报表
    driver.find_element('xpath','//*[@id="dialog_panel"]/div[9]/button[1]/span').click()
    time.sleep(10)
    #跳转活动中心
    driver.get('https://132.122.251.27:31943/ossfacewebsite/index.html#Access/MAE_Activities?switch')
    time.sleep(2)
    driver.find_element('xpath','//*[@id="eui_layout_10000"]').click()
    time.sleep(1)
    #下载存量表
    ActionChains(driver).move_by_offset(568, 789).click().perform()
    time.sleep(5)